﻿@{
    string guid = Html.Guid();
    CurrentUser user = ViewBag.CurrentUser;
    int id = ViewBag.CurrentSiteId;
}
<div class="current-location">
    <ul>
        <li class="left"><i class="glyphicon glyphicon-home"></i><span>@ViewBag.CurrentSiteName</span> &gt; <a href="javascript:void(0)">站点设置</a></li>
    </ul>
</div>
<div class="main">
    <script src="~/Incs/UEditor/ueditor.forAdmin.config.js" type="text/javascript"></script>
    <script src="~/Incs/UEditor/ueditor.all.min.js" type="text/javascript"></script>
    <form class="form" method="post" id="_form" data-source="@Model" data-validate-params="tipsStyle:1,beforeSubmit:'BeforeSubmit'">

        <div class="form-group">
            <label class="control-label">站点名称</label>
            <div class="controls">
                <input type="text" value="" class="form-control" maxlength="50" id="Name" name="Name" data-validate="dataType:'*',nullMsg:'请填写站点名称!'" />
                <span class="help-block">默认作为站点的标题后缀</span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label">访问目录</label>
            <div class="controls">
                <input type="text" id="Directory" name="Directory" class="form-control" data-validate="dataType:'string',nullMsg:'请填写访问目录！',checkUrl:'@Url.Action("CheckExists",new { id =id ,area="admin" })',checkError:'目录已存在，请重新设置'" maxlength="20" />
                <input type="hidden" id="old_directory" name="old_directory" />
                <span class="help-block">如果网站未绑定域名，则用主域名+访问目录形式访问，<span class="text-danger">修改后必须重启进程才生效。</span></span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label">绑定域名</label>
            <div class="controls">
                <input name="Domain" id="Domain" type="text" class="form-control" />
                <span class="help-block">如：http://www.domain.cn，留空则用主域名+目录访问网站,如有采用非80端口，必须带上端口，<span class="text-danger">修改后必须重启进程才生效。</span></span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label">模板目录</label>
            <div class="controls form-inline">
                <div class="input-group">
                    <input name="TemplateDirectory" id="TemplateDirectory" type="text" maxlength="50" class="form-control form-control-sm form-com" data-validate="dataType:'*',nullMsg:'请选择模板目录!'" />
                    <span class="input-group-btn">
                        <button class="btn btn-default ui-dialog" type="button" data-custom-params="title:'选择模板目录',url:'@Url.ActionUrl("SelectTemplate","TemplateManager")?objname=#TemplateDirectory',width:'500px',height:'90%',target:'_self'">选择目录</button>
                    </span>
                </div>
                <span class="help-block" id="_ValidateTips_TemplateDirectory">模板目录在/Templates目录下，填写或修改时请确认目录是否存在，修改后需要重启进程才生效</span>
            </div>
        </div>

        @{
        string beforeSubmitJs = "";
        var fieldData = Html.GetFieldList("pa_site", "Add", user);
        var data = new ViewDataDictionary();
        data = new ViewDataDictionary();
        data.Add("from", "admin");
        data.Add("guid", guid);
        data.Add("currentUser", user);
        data.Add("detailId", id);
        data.Add("i", 0);
        int i = 0;
        if (fieldData != null)
        {
            foreach (var row in fieldData)
            {
                data["i"] = i;
                beforeSubmitJs += row.BeforeSubmitJs;
                Html.RenderPartial("~/Areas/E/Views/CustomForm/FormPartial.cshtml", (object)row, data);
                i++;
            }
        }
        }


        <div class="form-group">
            <label class="control-label">Gzip压缩</label>
            <div class="controls">
                <select name="Compression" id="Compression" class="form-control form-control-sm">
                    <option value="1">开启</option>
                    <option value="0">关闭</option>
                </select>
                <span class="help-block">压缩可减少带宽消耗和提升访问速度，如果服务器的IIS中已开启了Gzip压缩，网站中就不需要再开启。</span>
            </div>
        </div>


        @*<div class="form-group">
            <label class="control-label" for="xuhao">序号</label>
            <div class="controls">
                <input type="text" name="xuhao" id="xuhao" maxlength="3" value="1" class="form-control form-control-xs" data-validate="dataType:'num">
                <span class="help-block"></span>
            </div>
        </div>*@
        <div class="submit-footerbar">
            <label class="control-label"></label>
            <div class="controls">
                <input type="hidden" id="Id" name="Id" value="@id" />
                <input type="hidden" id="isDefault" name="isDefault" />
                <input type="hidden" id="Guid" name="Guid" value="@guid" />
                <input type="hidden" id="Remark" name="Remark" />
                <button type="button" class="btn btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl("Edit")',callBack:'',beforeExecute:'BeforeExecute'" id="bt_submit">提交保存</button>
                <span class="help-block"></span>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    //初始化tab插件
    function BeforeExecute() {
        var $domain = $("#Domain")
        var domainVal = $domain.val();
        $domain.val(domainVal.toLocaleLowerCase());
        return true;
    }
    $("#_form").FormBind({ dataSourceFrom: "attr" });
   function BeforeSubmit()
    {
         @Html.Raw(beforeSubmitJs)
        return true;
    }
</script>
